package org.jeecg.modules.app.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.app.entity.Order;
import org.jeecg.modules.app.entity.ShopInfo;
import org.jeecg.modules.app.mapper.OrderMapper;
import org.jeecg.modules.app.mapper.ShopMapper;
import org.jeecg.modules.app.vo.OrderChartVO;
import org.jeecg.modules.app.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.app.entity.CustomerAddress;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 李圳川
 * @version 1.0
 * @date 2022/6/25 1:11
 * @content
 */
@Api(tags="web首页图表信息")
@RestController
@RequestMapping("/schoolOrder/web")
@Slf4j
public class ChartController {

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private ShopMapper shopMapper;

    /**
     *   查询所有订单
     * @return
     */
    @AutoLog(value = "查所有订单")
    @ApiOperation(value="查询所有订单", notes="查所有订单")
    @GetMapping(value = "/selectAllOrder")
    public Result<?> selectAllOrder() {
        QueryWrapper<Order> queryWrapper = new QueryWrapper<>();
        List<Order> orderList = orderMapper.selectList(null);
        return Result.success("200","查询所有订单",orderList);
    }

    /**
     *  查询订单总数和总金额
     * @return
     */
    @AutoLog(value = "查询订单总数和总金额")
    @ApiOperation(value="查询订单总数和总金额", notes="查询订单总数和总金额")
    @GetMapping(value = "/selectOrderChart")
    public Result<?> selectOrderChart() {
        OrderChartVO orderChartVO = orderMapper.selectOrderChart();
        return Result.success("200","查询成功",orderChartVO);
    }


    /**
     *  按月销降序排序
     * @return
     */
    @AutoLog(value = "按月销降序排序")
    @ApiOperation(value="按月销降序排序", notes="按月销降序排序")
    @GetMapping(value = "/selectShopInfoOrderBySellCount")
    public Result<?> selectShopInfoOrderBySellCount() {
       List<ShopInfo> shopInfoList = shopMapper.selectShopInfoOrderBySellCount();
       return Result.success("200","查询成功",shopInfoList);
    }




}
